//
//  Meeting.m
//  ZhumuSDKSample
//
//  Copyright 2006-2015 SUIRUI Co., Ltd. All rights reserved.
//

#import "Meeting.h"

#define kUID_KEY @"id"
#define kNAME_KEY @"username"
#define kOWNER_KEY @"isowner"
#define kTOKEN_KEY @"token"
#define kPMI_KET @"pmi"
#define kMSG_KEY @"msg"

#define kCODE_KEY @"code"
#define kZCODE_KEY @"zcode"
#define kMOBILE_KEY @"mobile"
#define kUSERTYPE_KEY @"usertype"
#define kDET_KEY @"det"
#define kCREATETIME_KEY @"createtime"
#define kCREATEBY_KEY @"createby"
#define kROLE_KEY @"role"
#define kEMAIL_KEY @"email"

@implementation Meeting

@end


////////////////////////////////////////////////////////////////////////


@implementation RequestMeeting

-(instancetype)initWithKey:(NSString *)key secret:(NSString *)secret type:(NSInteger)type name:(NSString *)name
{
    self = [super init];
    if (nil != self) {
        
        self.api_key = key;
        self.api_secret = secret;
        self.login_type = type;
        self.login_name = name;
        
    }
    return self;
}

#if !__has_feature(objc_arc)
-(void)dealloc
{
    [_api_key release];
    [_api_secret release];
    [_login_name release];
    [super dealloc];
}
#endif

@end


////////////////////////////////////////////////////////////////////////


@implementation MeetingInfo

-(instancetype)initWithDictData:(NSDictionary *)dic
{
    self = [super init];
    if (nil != self) {
        
        self.userID = dic[kUID_KEY];
        self.userName = dic[kNAME_KEY];
        if (dic[kOWNER_KEY] != [NSNull null] && 0 == [dic[kOWNER_KEY] integerValue]) {
            self.isOwner = YES;
        }
        self.token = dic[kTOKEN_KEY];
        self.meetingID = dic[kPMI_KET];
    
    }
    return self;
}


-(instancetype)initWithName:(NSString *)name meetingID:(NSString *)meetingID
{
    self = [super init];
    if (nil != self) {
        self.userName = name;
        self.meetingID = meetingID;
    }
    return self;
}


#if !__has_feature(objc_arc)
-(void)dealloc
{
    [_userID release];
    [_userName release];
    [_token release];
    [_meetingID release];
    [super dealloc];
}
#endif

@end


////////////////////////////////////////////////////////////////////////


@implementation MeetingFullInfo

-(instancetype)initWithDictData:(NSDictionary *)dic
{
    self = [super initWithDictData:dic];
    if (nil != self) {

        //NSLog(@"%@",dic[kCODE_KEY]);
        if (dic[kCODE_KEY] != nil) {
            self.code = [dic[kCODE_KEY] integerValue];
            if (_code == 200) {
                self.msg = dic[kMSG_KEY];
            }
        } else {
            self.code = 100;//认为成功
        }
        self.zcode = dic[kZCODE_KEY];
        self.mobile = dic[kMOBILE_KEY];
        self.usertype = (dic[kUSERTYPE_KEY] == [NSNull null])? -1 : [dic[kUSERTYPE_KEY] integerValue];
        self.det = dic[kDET_KEY];
        self.createtime = dic[kCREATETIME_KEY];
        self.createby = dic[kCREATEBY_KEY];
        self.role = dic[kROLE_KEY];
        self.email = dic[kEMAIL_KEY];
        
        //数据保护
        if ((dic[kPMI_KET] == [NSNull null]) || (dic[kTOKEN_KEY] == [NSNull null]))
        {
            self.code = 200;
            self.msg = @"无信息";
        }
        
    }
    return self;
}


#if !__has_feature(objc_arc)
-(void)dealloc
{
    [_zcode release];
    [_mobile release];
    [_det release];
    [_createtime release];
    [_createby release];
    [_role release];
    [_email release];
    [_msg release];
    [super dealloc];
}
#endif

@end
